package pers.zb.cloud.web.upms.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import pers.zb.cloud.web.upms.entity.SysMenu;
import pers.zb.cloud.web.upms.service.hystrix.MenuServiceHystrix;
import pers.zb.cloud.web.upms.vo.MenuVo;

import java.util.List;

@FeignClient(value = "sea-cloud-service-upms", fallback = MenuServiceHystrix.class)
public interface MenuService {

	/**
	 * 根据父ID获取菜单列表
	 *
	 * @param pid 父ID
	 * @param from 1 - 首页左侧菜单的加载   2 - 菜单列表页面的加载
	 * @param clientId
	 * @return
	 */
	@RequestMapping(value = "/upms/service/menu/list/{pid}/{from}",method = RequestMethod.POST)
	List<MenuVo> getMenuListByPid(@PathVariable("pid") Long pid, @PathVariable("from") int from, @RequestParam("clientId") String clientId);

	/**
	 * 根据ID获取菜单
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/upms/service/menu/{id}",method = RequestMethod.GET)
	SysMenu getMenuById(@PathVariable("id") Long id);

	/**
	 * 获取出自身外的其他所有可用的菜单
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/upms/service/menu/list/not/itself/{id}/{clientId}",method = RequestMethod.GET)
    List<MenuVo> getMenuListByNotItself(@PathVariable("id") Long id,@PathVariable("clientId") String clientId);

	/**
	 * 更新菜单
	 */
	@RequestMapping(value = "/upms/service/menu",method = RequestMethod.POST)
	void updateMenu(@RequestBody SysMenu sysMenu) throws Exception;

	/**
	 * 删除菜单
	 */
	@RequestMapping(value = "/upms/service/menu/batch",method = RequestMethod.POST)
    void deleteMenu(@RequestParam("id") Long[] id) throws Exception;

	/**
	 * 判断是否具有子节点
	 */
	@RequestMapping(value = "/upms/service/menu/children/have/{id}",method = RequestMethod.GET)
	boolean haveChildrenMenu(@PathVariable("id") Long id);

	/**
	 * 新增菜单
	 */
	@RequestMapping(value = "/upms/service/menu",method = RequestMethod.POST)
    void addMenu(@RequestBody SysMenu sysMenu) throws Exception;

}
